package com.jusfoun.communication.controller;

import com.jusfoun.communication.model.AutoReply;
import com.jusfoun.communication.service.AutoReplyService;
import com.jusfoun.communication.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

/**
 * 自动回复相关controller
 *
 * @author player six
 * @email jslcylcy@163.com
 * @create 2018-01-29 14:36
 **/
@RestController
@ApiIgnore
@RequestMapping("/autoreply")
public class AutoReplyController {

    @Autowired
    private AutoReplyService autoReplyService;

    /**
     * 保存是否自动回复的配置信息
     *
     * @param appId
     * @param useAutoReply
     * @param autoReplyBegin
     * @param autoReplyEnd
     * @return
     */
    @RequestMapping(value = "/configure", method = RequestMethod.POST)
    public Result saveConfigure(String appId, boolean useAutoReply, String autoReplyBegin, String autoReplyEnd) {
        return autoReplyService.saveConfigure(appId, useAutoReply, autoReplyBegin, autoReplyEnd);
    }

    /**
     * 新增自动回复信息
     *
     * @param autoReply
     * @return
     */
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public Result addAutoReply(AutoReply autoReply) {
        return autoReplyService.addAutoReply(autoReply);
    }

    /**
     * 更新自动回复信息
     *
     * @param autoReply
     * @return
     */
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public Result updateAutoReply(AutoReply autoReply) {
        return autoReplyService.updateAutoReply(autoReply);
    }

    /**
     * 批量删除
     *
     * @param idList
     * @param appId
     * @return
     */
    @RequestMapping(value = "/del", method = RequestMethod.POST)
    public Result delAutoReply(@RequestParam("idList[]") List<Long> idList, String appId) {
        return autoReplyService.delAutoReply(idList, appId);
    }
}
